﻿using System.Collections.Generic;
using System.ComponentModel;
using Koonsoft.HYCRM.DAL;
using Koonsoft.HYCRM.Model;

namespace Koonsoft.HYCRM.BLL
{
    [DataObject]
    public class BranchBLL
    {
        private BranchDAL _dal = null;

        protected BranchDAL DAL
        {
            get
            {
                if (_dal == null)
                {
                    _dal = new BranchDAL();
                }

                return _dal;
            }
        }

        /// <summary>
        /// 根据登录名获取所属分行ID
        /// </summary>
        /// <param name="loginName"></param>
        /// <returns></returns>
        public int GetBranchIDByLoginName(string loginName)
        {
            return DAL.GetBranchIDByLoginName(loginName);
        }

        /// <summary>
        /// 根据分行ID获取分行名称
        /// </summary>
        /// <param name="branchID"></param>
        /// <returns></returns>
        public string GetBranchNameByBranchID(int branchID)
        {
            return DAL.GetBranchNameByBranchID(branchID);
        }

        /// <summary>
        /// 获取所有的分行信息
        /// </summary>
        /// <returns></returns>
        public List<BranchInfo> GetBranches()
        {
            return DAL.GetBranches();
        }
    }
}
